import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import homeRoutes from "./module/home";
import mapRoutes from './module/map'
import userRoutes from './module/user'
import cDetailRoutes from "@/router/module/cDetail";
import vDetailRoutes from "@/router/module/vDetail";
import lookRoutes from "@/router/module/look";
import userActionRoutes from "@/router/module/userAction";
Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
    {
        path: '/',
        redirect: '/home'
    },
    ...homeRoutes,
    ...userRoutes,
    ...mapRoutes,
    ...cDetailRoutes,
    ...vDetailRoutes,
    ...lookRoutes,
    ...userActionRoutes
]

const router = new VueRouter({
  routes
})

//防止路由重复跳转报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location:any) {
    return (originalPush.call(this, location) as any).catch((err:any) => err)
}
export default router
